{ pkgs, ... }:
{
  boot.kernelModules = [ "kvmgt" "mdev" "vfio" "vfio-mdev" "vfio_iommu_type1" "vfio_pci" "vfio_virqfd" ];
  boot.kernelParams = [ "intel_iommu=on" "iommu=pt" "i915.enable_gvt=1" "i915.enable_guc=0" ];

  users.extraUsers.sny = {
    extraGroups = [ "qemu-libvirtd" "libvirtd" ];
  };

  users.groups.libvirtd.members = [ "root" "sny" ];

  environment.systemPackages = with pkgs; [
    virt-manager qemu OVMF
  ];
  
  environment.variables = {
    GVT_DOM  = "0000:00";
    GVT_PCI  = "0000:00:02.0";
    GVT_TYPE = "i915-GVTg_V5_4";
    GVT_GUID = "a70fa95c-4a30-4829-b1a1-4520d19224ce";
  };
  
  virtualisation.libvirtd.enable = true;

  virtualisation.libvirtd.qemuVerbatimConfig = ''
    nvram = [ "${pkgs.OVMF}/FV/OVMF.fd:${pkgs.OVMF}/FV/OVMF_VARS.fd" ]
  '';
}
